﻿using MediatR;
using SheepCultivation.Common.Domain.PurchaseSales;
using SheepCultivation.Common.Dto;
using SheepCultivation.Common.Infrastructure.Interface;
using SheepCultivation.Enum;

namespace SheepCultivation.API.AddliCation.PurchaseSales
{
    public class AbsrtactSeachHandler : IRequestHandler<AbsrtactSeachCommon, Result>
    {
        public readonly IBaseRepository<Absrtact> AbsrtactRepository;
        public AbsrtactSeachHandler(IBaseRepository<Absrtact> absrtactRepository)
        {
            AbsrtactRepository = absrtactRepository;
        }

        public async Task<Result> Handle(AbsrtactSeachCommon request, CancellationToken cancellationToken)
        {
            var res = new Result() { Code = (int)CommonEnumCode.error };
            try
            {
                var list = AbsrtactRepository.GetAll().ToList();
                res.Code = (int)CommonEnumCode.success;
                res.Data = list;
                res.Msg = "摘要显示";
            }
            catch (Exception)
            {

                throw;
            }
            return res;
        }
    }
}
